package com.auxgroup.smarthome.inner.repo;

import com.auxgroup.smarthome.inner.entity.DeviceFaultEntity;
import com.auxgroup.smarthome.repo.GenericDao;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * Created by lixiaoxiao on 17-8-7.
 */
public interface DeviceFaultRepo  extends GenericDao<DeviceFaultEntity,String> {

    @Query(value = "select * from device_fault f" +
            " where f.mac LIKE ?1 ORDER BY f.occurrence_time desc limit ?2,?3",nativeQuery = true)
    List<DeviceFaultEntity> findByMac(String mac,int page,int size);

    DeviceFaultEntity findByMacAndStatus(String mac,int status);

    @Query(value = "select * from device_fault f" +
            " where f.uid LIKE ?1 ORDER BY f.occurrence_time DESC ",nativeQuery = true)
    List<DeviceFaultEntity> findByUid(String uid);
}
